<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<% String path = request.getContextPath();%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>物流白名单 修改</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body>
<form id="mcrLgsUsr_form">
    <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
        <div class="fieldBox col_50">
            <div class="label">客户名称</div>
            <div class="field">
                <input name="cstNm" id="cstNm" type="text" readOnly="true" class="ui-textbox" value="" validate="{required:true, minlength:2, maxlength:50}">
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">证件号码</div>
            <div class="field">
                <input name="certNo" id="certNo" type="text" readOnly="true" class="ui-textbox" value="" validate="{required:true, minlength:18, maxlength:18}">
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">手机号码</div>
            <div class="field">
                <input name="mobileNo" id="mobileNo" type="text" readOnly="true" class="ui-textbox" value="" validate="{required:true, minlength:11, maxlength:11, digits:true}">
            </div>
        </div>
        <div class="fieldBox col_50">
            <div class="label">认证步骤</div>
            <div class="field">
                <select name="mdfStp" id="mdfStp">
                    <option value="0">未认证</option>
                    <option value="1">实名认证</option>
                    <option value="2">个人信息</option>
                    <option value="3">车辆信息</option>
                    <option value="4">车辆状态</option>
                </select>
            </div>
        </div>

        <div class="fieldset1 clearFix">
            <div class="fieldBox">
                <div class="label">车辆行驶证</div>
                <div class="field">
                    <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload6.jsp" flush="true" >
                        <jsp:param name="filePath" value="/mcrVehiclePhoto"/>
                        <jsp:param name="countLimit" value="2"/>
                    </jsp:include>
                </div>
            </div>
        </div>

        <!-- hide data -->
        <div class="fieldBox col_100" style="display:none;">
            <div class="field">
                <input name="dataId" id="dataId" type="text" class="ui-textbox" value="${id}">
            </div>
        </div>
        <div class="fieldBox col_100" style="display:none;">
            <div class="field">
                <input name="busType" id="busType" type="text" class="ui-textbox" value="">
            </div>
        </div>
    </div>
</form>

<script>
    $(function() {
        $("#mcrLgsUsr_form").ligerForm({
            validate: true
        });
        /*  if($("#dataId").val()){
             $("#knotStarttimeStr").attr("disabled","true");
             $("#knotStarttimeStr").removeAttr("class");
             $("#knotStarttimeStr").attr("class","ui-textbox");
         } */
        initData();
    });

    //定义父级调用事件
    frameElement.dialog.onOk = function () {
        save();
    }

    frameElement.dialog.onCancel = function () {
        frameElement.dialog.close();
    }

    //保存
    function save(){
        var ligerForm = liger.get("mcrLgsUsr_form");
        var loanId = $("#loanId").val();
        var fileParams = getUploadResultParams();//获取附件上传的信息
        if (!ligerForm.valid()) {
            UIUtils.alertWarning("有验证信息未通过!");
            return; //验证不通过，不执行以下代码
        }
        var data = ligerForm.getData();
        var dataId = $("#dataId").val();
        var url = '<%=path%>/mcr/mcrLgsUsr/add.do';
        if(StringUtils.isNotEmpty(dataId)){
            url = '<%=path%>/mcr/mcrLgsUsr/modify.do';
            data["id"]= dataId;
            data["fileParams"]= JSON.stringify(fileParams);
        }
        AjaxUtils.ajaxPost(url, data, addCallback);
    }


    //新增回调
    function addCallback(msg){
        if(msg.success == 1){
            parent.grid.reload();
            //parent.$.ligerDialog.SQalert({content:'提示内容', SQ_type: "success"});
            UIUtils.alertSuccess("操作成功!");
            frameElement.dialog.close();
        }else{
            UIUtils.alertError(msg.info);
        }
    }

    //修改初始化数据
    function initData(){
        var dataId = $("#dataId").val();
        if(StringUtils.isEmpty(dataId))return;
        var _url = '<%=path%>/mcr/mcrLgsUsr/getById.do';
        AjaxUtils.ajaxGet(_url, {id:dataId}, initCallback);
    }

    //初始化回调
    function initCallback(msg){
        if(msg.success == 1){
            setData(msg.data);//设置数据
        }else{
            UIUtils.alertError(msg.info);
        }
    }

    //修改时候设置页面数据
    function setData(data){
        var form = new liger.get("mcrLgsUsr_form");
        form.setData({
            cstNm:data.cstNm,
            certNo:data.certNo,
            mobileNo:data.mobileNo,
            mdfStp:data.mdfStp,
            busType:data.busType
        });
    };
</script>

</body>
</html>